<!-- 95% W3C COMPLIANT, 95% CSS FREE, RAW HTML -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Introduction to Maya Exporters</title>
 <style type="text/css">
  <!--
  pre { font-family: monospace }
  tt { font-family: monospace }
  code { font-family: monospace }
  p.flushright { text-align: right }
  p.flushleft { text-align: left }
  span.sc { font-variant: small-caps }
  span.sf { font-family: sans-serif }
  span.skribetitle { font-family: sans-serif; font-weight: bolder; font-size: x-large; }
  -->
 </style>
</head>

<body class="chapter" bgcolor="#ffffff">
<table width="100%" class="skribetitle" cellspacing="0" cellpadding="0"><tbody>
<tr><td align="center" bgcolor="#8381de"><div class="skribetitle"><strong><big><big><big>3. gpExport - a Maya Exporter -- Interfacing with Maya</big></big></big></strong></div><center>
</center>
</td></tr></tbody></table>
<table cellpadding="3" cellspacing="0" width="100%" class="skribe-margins"><tr>
<td align="left" valign="top" class="skribe-left-margin" width="20%" bgcolor="#dedeff"><div class="skribe-left-margin">
<br/><center><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
<tr bgcolor="#8381de"><th align="center" colspan="1"><font color="#ffffff"><strong>main page</strong></font></th></tr>
<tr bgcolor="#ffffff"><td align="center" colspan="1"><table width="100%" border="0" style="border-collapse: collapse;" frame="void" rules="none"><tbody>
<tr><td align="left" valign="top" colspan="1"><strong>top:</strong></td><td align="right" valign="top" colspan="1"><a href="maya-export.html#gpExport---a-Maya-Exporter" class="inbound">gpExport - a Maya Exporter</a></td></tr>
</tbody></table>
</td></tr>
</tbody></table>
</center>
<br/><br/><center><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
<tr bgcolor="#8381de"><th align="center" colspan="1"><font color="#ffffff"><strong>Interfacing with Maya</strong></font></th></tr>
<tr bgcolor="#ffffff"><td align="center" colspan="1"><table cellspacing="1" cellpadding="1" width="100%" class="toc">
<tbody>
 <tr><td valign="top" align="left">3.2</td><td colspan="4" width="100%"><a href="maya-export-3.html#Executable">Executable</a></td></tr>
</tbody>
</table>
</td></tr>
</tbody></table>
</center>
<br/><br/><center><table width="97%" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" frame="box" rules="none"><tbody>
<tr bgcolor="#8381de"><th align="center" colspan="1"><font color="#ffffff"><strong>Chapters</strong></font></th></tr>
<tr bgcolor="#ffffff"><td align="center" colspan="1"><table cellspacing="1" cellpadding="1" width="100%" class="toc">
<tbody>
 <tr><td valign="top" align="left">1</td><td colspan="4" width="100%"><a href="maya-export-1.html#Introduction">Introduction</a></td></tr>
 <tr><td valign="top" align="left">2</td><td colspan="4" width="100%"><a href="maya-export-2.html#Coding-styles-and-Conventions">Coding styles and Conventions</a></td></tr>
 <tr><td valign="top" align="left">3</td><td colspan="4" width="100%"><a href="maya-export-3.html#Interfacing-with-Maya">Interfacing with Maya</a></td></tr>
 <tr><td valign="top" align="left">4</td><td colspan="4" width="100%"><a href="maya-export-4.html#Extraction">Extraction</a></td></tr>
 <tr><td valign="top" align="left">5</td><td colspan="4" width="100%"><a href="maya-export-5.html#gpExport">gpExport</a></td></tr>
 <tr><td valign="top" align="left">6</td><td colspan="4" width="100%"><a href="maya-export-6.html#References">References</a></td></tr>
</tbody>
</table>
</td></tr>
</tbody></table>
</center>
</div></td>
<td align="left" valign="top" class="skribe-body"><div class="skribe-body">
<p>At first I didn't have the intention on writing this chapter, and
   I still think, that there's no need to write it. This part is surprisingly
   well document in Maya's help and on the Net. I'm therefore rather summarizing
   the techniques, than explaining every detail. Feel free to look for more
   information on the web, or even to complement this chapter (it's open-doc,
   isn't it;).<p>In order to write an exporter one needs to interface in some way with
   Maya. The more obvious one is of course by writing a plugin, and
   implementing Maya's &quot;interfaces&quot;. Another interesting approach consists in
   writing a stand-alone application, that just uses Maya's libraries. I
   recommend keeping the exporter general enough, so it can be used as both.</p><!-- Plugin -->
<a name="Plugin"></a>
<div class="skribesectiontitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">3.1 Plugin</font>
</h3></td></tr></table>
</div><div class="section">
If the exporter should be accessible from within Maya, the exporter needs
   to derive from <code>MPxFileTranslator</code>. Furthermore some methods must be
   implemented:
   <ul class="itemize"><li><code>haveReadMethod</code>: most of the time returns
					   <code>false</code>.</li>
<li><code>haveWriteMethod</code>: most of the time returns
					    <code>true</code>.</li>
<li><code>reader</code>: most of the time returns an error.</li>
<li><code>writer</code>: exports the scene. <strong>The</strong> method, that
				does all the work.</li>
<li><code>identifyFile</code>: recognizes the plugin's files
				       (or not;).</li>
<li><code>defaultExtension</code>: obvious.</li>
</ul>
   Note however, that <code>gpExport</code> already does all this work for
   you. By reusing the framework only two methods need to be implemented:
   <ul class="itemize"><li><code>Export</code>: more or less equivalent to <code>writer</code></li>
<li><code>getExtension</code>: more or less equivalent to
				      <code>defaultExtension</code></li>
</ul></div><br>
</p><!-- Executable -->
<a name="Executable"></a>
<div class="skribesectiontitle"><table width="100%"><tr><td bgcolor="#dedeff"><h3><font color="black">3.2 Executable</font>
</h3></td></tr></table>
</div><div class="section">
<p>Writing an executable is even easier (as long as one knows what libraries
   are needed, and how to link them to your executable). One just needs to
   initialize the <code>MLibrary</code>, which can be conveniently done using
   <code>gpExport</code>'s <code>MayaLibrary</code>-class. In the latter case one just needs
   instantiate this class, as shown in <code>executable.cpp</code>:</p><p><table cellspacing="0" class="frame" cellpadding="2" border="1" width="100%"><tbody>
<tr><td><pre class="prog"><em>54: </em>        MayaLibrary library((char*)exporterName.c_str());
<em>55: </em>
<em>56: </em>        loadScene(inFile);
<em>57: </em>
<em>58: </em>        MFileObject outMFile;
<em>59: </em>        outMFile.setFullName(outFile.c_str());
<em>60: </em>        ExporterConfig config(outMFile, <font color="red">&quot;&quot;</font>, false);
<em>61: </em>
<em>62: </em>        exporter.Export(config);
</pre>
</td></tr>
</tbody></table></p><p>I might say: this file is an excellent example of a
   Maya-executable;). Compiling the cpp-file is then easy. What's way more
   difficult is the linking. I heavily advise to reuse <code>gpExport</code>'s
   Makefile. It could save you a lot of time...</p></div><br>
</div></td>
</tr></table><div class="skribe-ending">
<hr> 
<p class="ending"><font size="-1">
This <span class="sc">Html</span> page has been produced by 
<a href="http://www.inria.fr/mimosa/fp/Skribe" class="http">Skribe</a>.
<br/>
Last update <em>Sun Sep  5 10:44:30 2004</em>.</font></p></div>
</body>
</html>